<?php
defined('_VISIT_URL_') or exit('No direct script access allowed');

class record {

	//获取自动化日志列表
	public function getAutologList() {
		$module = getPost('moduleInfo');
		$operater = getPost('operaterInfo');
		$status = getPost('statusInfo');
		$startdate = getPost('startdate');
		$page = getPost('page', '1');
		$permission = getPost('permission');

		$queryitem = '';
		if ($module != '')
			$queryitem .= " and module = '" . $module . "'";
		if ($operater != '')
			$queryitem .= " and operater = '" . $operater . "'";
		if ($status != '')
			$queryitem .= ' and status = ' . $status;
		if ($startdate != '')
			$queryitem .= " and starttime >= '" . $startdate . "'";

		$limititem = ' limit ' . ($page - 1) * 50 . ', 50';
		$sortOption = 'starttime desc, id desc';

		$rst = new sqlcon();

		$info = $rst->getInfo('count(*) as num', 'autolog', 'id != 0' . $queryitem);

		$list = $rst->getList('logid, module, operater, autoer, status, result, starttime, endtime', 'autolog', 'id != 0' . $queryitem, $sortOption . $limititem);

		$result = util::getSuccess('success');
	    $result['listCount'] = $info['num'];
	    $result['allPages'] = util::getListPage($info['num'], 50);
	    $result['autolog'] = $list;
	    $result['rowCount'] = 50;
	    if ($permission == 'yes') {
	    	$result['permission'] = util::getOperateItem(getPost('menuid'));
	    }
		return $result;
	}

}